
/*
* @ author: karim daher
* @ date: 04-28-2008
* @version: 0.1
 */

class Person {
	static transients = ["pass"]
	static hasMany=[authorities:Authority, freinds:Person]
	static belongsTo = Authority

	String          username
	String          userRealName
	String          passwd
    String          oldPasswd // used to authenticate user when editing user
    //String          cpasswd // used to validate passwd confirmation
    String          confirmationCode = ""
 
    boolean         enabled = false
	String          email
	boolean         email_show = false
	String          description=""
    //String          gender
    String          city
    String          state
    String          country
    MemberProfile   profile
    Person          referedBy


    /** plain password to create a MD5 password */
	String pass="[secret]"

	static def constraints = {
		username(blank:false,unique:true)
		userRealName(blank:false)
        //gender(inList:["Male","Female"])
        city(blank:true, nullable:true)
        state(blank:true, nullable:true)
        country(blank:true, nullable:true)
        referedBy(nullable:true)
        profile(nullable:true)
        oldPasswd(nullable:true)
        enabled()
        passwd(blank:false,matches:/[\w\d]+/,size:6..32)
        email(blank:false,email:true,unique:true)
	}
}